home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q1082.dms / q1082.adf / src.lzh / Fig / box.c < prev    next >
C/C++ Source or Header  |  1991-07-18  |  3KB  |  121 lines

  1. /* 
  2.  *    FIG : Facility for Interactive Generation of figures
  3.  *
  4.  *    Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
  5.  *    January 1985.
  6.  *    1st revision : Aug 1985.
  7.  *
  8.  *    %W%    %G%
  9. */
  10. #include "fig.h"
  11. #include "resources.h"
  12. #include "alloc.h"
  13. #include "func.h"
  14. #include "object.h"
  15. #include "paintop.h"
  16.  
  17. extern int        cur_line_style, line_thickness;
  18. extern float        cur_styleval;
  19. extern int        cur_color;
  20. extern int        fix_x, fix_y, cur_x, cur_y;
  21. extern            (*canvas_kbd_proc)();
  22. extern            (*canvas_locmove_proc)();
  23. extern            (*canvas_leftbut_proc)();
  24. extern            (*canvas_middlebut_proc)();
  25. extern            (*canvas_rightbut_proc)();
  26. extern            null_proc();
  27. extern            set_popupmenu();
  28.  
  29. extern F_compound    objects;
  30.  
  31. /*************************** locally global procedures *********************/
  32.  
  33.             elastic_box();
  34. int            create_boxobject();
  35.             init_box_drawing();
  36.  
  37. box_drawing_selected()
  38. {
  39.     canvas_kbd_proc = null_proc;
  40.     canvas_locmove_proc = null_proc;
  41.     canvas_leftbut_proc = init_box_drawing;
  42.     canvas_middlebut_proc = null_proc;
  43.     canvas_rightbut_proc = set_popupmenu;
  44.     set_cursor(&arrow_cursor);
  45.     reset_action_on();
  46.     }
  47.  
  48. init_box_drawing(x, y)
  49. int    x, y;
  50. {
  51.     cur_x = fix_x = x; 
  52.     cur_y = fix_y = y;
  53.     canvas_locmove_proc = elastic_box;
  54.     canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
  55.     canvas_middlebut_proc = create_boxobject;
  56.     draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT);
  57.     set_temp_cursor(&null_cursor);
  58.     set_action_on();
  59.     }
  60.  
  61. draw_rectbox(x1, y1, x2, y2, op)
  62. int    x1, y1, x2, y2, op;
  63. {
  64.     pw_vector(canvas_pixwin, x1, y1, x1, y2, op, 1);
  65.     pw_vector(canvas_pixwin, x1, y2, x2, y2, op, 1);
  66.     pw_vector(canvas_pixwin, x2, y2, x2, y1, op, 1);
  67.     pw_vector(canvas_pixwin, x2, y1, x1, y1, op, 1);
  68.     }
  69.  
  70. elastic_box(x, y)
  71. int    x, y;
  72. {
  73.     draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT);
  74.     cur_x = x;  
  75.     cur_y = y;
  76.     draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT);
  77.     }
  78.  
  79. create_boxobject(x, y)
  80. int    x, y;
  81. {
  82.     F_line    *box;
  83.     F_point    *point;
  84.  
  85.     draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT);
  86.  
  87.     
  88.     if ((Point_malloc(point)) == NULL) {
  89.         blink_msg();
  90.         put_msg(Err_mem);
  91.         return;
  92.         }
  93.     point->x = fix_x;
  94.     point->y = fix_y;
  95.     point->next = NULL;
  96.  
  97.     Line_malloc(box);
  98.     box->type = T_BOX;
  99.     box->style = cur_line_style;
  100.     box->thickness = line_thickness;
  101.     box->color = cur_color;
  102.     box->pen = NULL;
  103.     box->area_fill = NULL;
  104.     box->style_val = cur_styleval;
  105.     box->for_arrow = NULL;
  106.     box->back_arrow = NULL;
  107.     box->points = point;
  108.     box->next  = NULL;
  109.     append_point(x, fix_y, &point);
  110.     append_point(x, y, &point);
  111.     append_point(fix_x, y, &point);
  112.     append_point(fix_x, fix_y, &point);
  113.     draw_line(box, PAINT);
  114.     clean_up();
  115.     set_action_object(F_CREATE, O_POLYLINE);
  116.     insert_line(&objects.lines, box);
  117.     set_latestline(box);
  118.     set_modifiedflag();
  119.     box_drawing_selected();
  120.     }
  121.